﻿using System;

namespace ArrayValidation
{
    /// <summary>
    /// 利用数组验证改变形参的值是否会影响实参的值
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Console.Clear();
            int[] array = { 1,3,4,5,7 };
            Console.WriteLine("原数组：");
            for (int i = 0; i < 5; i++)
            {
                Console.Write(array[i]);
                Console.Write(" ");
            }
            Function(array);
            Console.WriteLine();
            Console.WriteLine("调用函数后的数组：");
            for (int i = 0; i < 5; i++)
            {
                Console.Write(array[i]);
                Console.Write(" ");
            }
            Console.ReadKey();
        }
        //调用函数
        static void Function(int[] array)
        {
            for (int j = 0; j < 5; j++)
            {
                array[j] = 2*j ;
            }
        }
    }
}
